package com.fanghaoran.view.user.viewFrame;

import com.fanghaoran.entity.InfoToDisplay;

import javax.swing.table.AbstractTableModel;
import java.util.List;

/**
 * @Author: win11
 * @Date: 2023/03/27/22:26
 * @Description: 用户间可互相查看的数据表格
 */
public class InfoToDisplayTableModel extends AbstractTableModel {
    private final String[] columnNames = { "用户名","性别", "昵称","学习总单词数","学习总时间","连续签到天数" };
    private final List<InfoToDisplay> userList;

    public InfoToDisplayTableModel(List<InfoToDisplay> userList) {
        this.userList = userList;
    }

    @Override
    public int getRowCount() {
        return userList.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        InfoToDisplay user = userList.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return user.getUsername();
            case 1:
                return user.getGender();
            case 2:
                return user.getNickname();
            case 3:
                return user.getWordAccount();
            case 4:
                return user.getStudyTime();
            case 5:
                return user.getclockDays();
            default:
                return null;
        }
    }


    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }
}
